class StringUtils:
    """字符串处理工具类"""

    @staticmethod
    def to_upper(string: str) -> str:
        """将字符串转换为大写"""
        return string.upper()

    @staticmethod
    def to_lower(string: str) -> str:
        """将字符串转换为小写"""
        return string.lower()

    @staticmethod
    def reverse_string(string: str) -> str:
        """反转字符串"""
        return string[::-1]

    @staticmethod
    def is_palindrome(string: str) -> bool:
        """判断字符串是否为回文"""
        cleaned_string = ''.join(e for e in string if e.isalnum()).lower()
        return cleaned_string == cleaned_string[::-1]

    @staticmethod
    def count_substring(string: str, substring: str) -> int:
        """统计子字符串在主字符串中出现的次数"""
        return string.count(substring)

    @staticmethod
    def remove_whitespace(string: str) -> str:
        """去除字符串中的空格"""
        return ''.join(string.split())

    @staticmethod
    def replace_substring(string: str, old: str, new: str) -> str:
        """替换字符串中的子字符串"""
        return string.replace(old, new)

    @staticmethod
    def starts_with(string: str, prefix: str) -> bool:
        """判断字符串是否以某前缀开始"""
        return string.startswith(prefix)

    @staticmethod
    def ends_with(string: str, suffix: str) -> bool:
        """判断字符串是否以某后缀结束"""
        return string.endswith(suffix)

    @staticmethod
    def capitalize_each_word(string: str) -> str:
        """将字符串中的每个单词首字母大写"""
        return string.title()
